
#define LED_ALL '5'
#define LED_1 '1'
#define LED_2 '2'
#define LED_3 '3'
#define LED_4 '4'
int main(void)
{

//    key_int_init();
    uart_init();
    led_init(0);
    led_init(1);
    led_init(2);
    led_init(3);
    led_off(1);
    led_off(2);
    led_off(3);
    led_off(4);
    unsigned char a = uart_recv();
    unsigned char c;
    short temp;
    while (1) {
        uart_send(a);
        int led[5]={0};
        if(a=='z'){     //  电子琴           
            while (1) {
                c = uart_recv();
                uart_send(c);
                switch (c) {
                case 'a':
                    bee_on(0x8);
                    break;
                case 's':
                    bee_on(0x9);
                    break;
                case 'd':
                    bee_on(0xa);
                    break;
                case 'f':
                    bee_on(0xb);
                    break;
                case 'g':
                    bee_on(0xc);
                    break;
                case 'h':
                    bee_on(0xd);
                    break;
                case 'j':
                    bee_on(0xe);
                    break;
                case 'k':
                    bee_off();
                    break;
                }
                if(c=='p')
                    break;
                }
        }
        else if (a == 'q') {    // 音乐播放
            key_int_init();
            play();
        }
        else if (a == 'X') {    //  温度
            temp = mpu6050_get_temperature();
            uart_printf("%d", temp);
            delay_time(5);
        }else{
            	int i;
	switch(b){
	case LED_1:
	case LED_2:
	case LED_3:
	case LED_4:
		led[b-'1']=!led[b-'1'];
		if(led[b-'1']) led_on(b-'1'); else led_off(b-'1');
		led[4]=0;
		break;
	case LED_ALL: 
		led[4]=!led[4];
		for(i=0;i<4;i++) {
			if(led[4]) {led[i]=1;
				led_on(i); }
			else {	led[i]=0;
				led_off(i);}
			}
			break;
			
		}
        }
        a = uart_recv();
    }

    return 0;
}
